document.getElementsByClassName("login-error")[0].style.display = "none"
document.getElementsByClassName("login-error")[1].style.display = "none"

document.getElementsByClassName("submit-success")[0].style.display = "none"


$('#login-btn').click(function(){

    document.getElementsByClassName("login-error")[0].style.display = "none"
    document.getElementsByClassName("login-error")[1].style.display = "none"

    if($("#formGroupExampleInput").val() == "" || $("#exampleInputPassword1").val() == ""){
        console.log("信息为空")
        document.getElementsByClassName("login-error")[1].style.display = "block"
        console.log(document.getElementsByClassName("login-error").length)
    }else {
        console.log("信息不为空")
        $.ajax({
            type: "GET",
            url: "login",
            data: {id:$("#formGroupExampleInput").val(), password:$("#exampleInputPassword1").val()},
            dataType: "json",
            success: function(data){
                if(data.hasOwnProperty("code")){
                    document.getElementsByClassName("login-error")[0].style.display = "block"
                }else{
                    document.getElementsByClassName("submit-success")[0].style.display = "block"
                    setTimeout(function(){window.location.href = "find.jsp"},1500);
                }
            }
        });
    }
});
